#include <string>
#include <stack>
#include <vector>
using namespace std;
class Solution {
public:
    int evalRPN(vector<string> &tokens) {
        stack<int> s;
        for (int i=0;i<tokens.size();i++)
            if (tokens[i]=="+" || tokens[i]=="-"|| tokens[i]=="*"|| tokens[i]=="/") {
                int a,b;
                b=s.top();s.pop();
                a=s.top();s.pop();
                switch (tokens[i][0]) {
                    case '+':
                        s.push(a+b);
                        break;
                    case '-':
                        s.push(a-b);
                        break;
                    case '*':
                        s.push(a*b);
                        break;
                    case '/':
                        s.push(a/b);
                        break;
                }
            } else s.push(stoi(tokens[i]));
        return s.top();
    }
};
